package net.sh.dpinfrastructure.client;

/**
 * 
 * 客户端信息
 * 
 * @author shaohui
 * @date: 2016年7月24日下午9:11:53 <br/>
 * @version
 * @since JDK 1.8
 */
public class ClientInfo {

    /**
     * ip 地址
     */
    private String ip;

    /**
     * 客户端类型
     */
    private ClientType clientType;
    
    /**
     * 客户端描述
     */
    private String clientDescription;
    
    

    public String getIp() {
        return ip;
    }



    public void setIp(String ip) {
        this.ip = ip;
    }



    public ClientType getClientType() {
        return clientType;
    }



    public void setClientType(ClientType clientType) {
        this.clientType = clientType;
    }



    public String getClientDescription() {
        return clientDescription;
    }



    public void setClientDescription(String clientDescription) {
        this.clientDescription = clientDescription;
    }



    /**
     * 
     * 客户端类型
     * 
     * @author shaohui
     * @date: 2016年7月24日下午9:13:02 <br/>
     * @version ClientInfo
     * @since JDK 1.8
     */
    public enum ClientType {
        
        BROWSER(1),

        ANDROID(2),

        IOS(3),

        WP(4),

        MACOS(5),

        LINUX(6),

        WINDOWS(7);

        private int code;

        private ClientType(int code) {
            this.code = code;
        }
        
        public int getCode() {
            return code;
        }

        public static ClientType valusOf(int code) {
            switch (code) {
                case 1: {
                    return BROWSER;
                }
                case 2: {
                    return ANDROID;
                }
                case 3: {
                    return IOS;
                }
                case 4: {
                    return WP;
                }
                case 5: {
                    return MACOS;
                }
                case 6: {
                    return LINUX;
                }
                case 7: {
                    return WINDOWS;
                }
                default: {
                    return null;
                }
            }
        }
    }
}
